<?php
declare (strict_types = 1);

namespace app\middleware;

use think\Request;

class FormTokenMiddleware
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return \think\response\Json
     */
    public function handle(Request $request, \Closure $next)
    {
        if ($request->checkToken('__token__') === false) return json(['code' => 0, 'message' => '页面失效,请刷新页面']);
        return $next($request);
    }
}
